package com.ss.android.action;

import android.content.ContentValues;
import android.content.SharedPreferences;

import com.bytedance.frameworks.b.a.ComponentsManifest;
import com.ss.android.cc;
import com.ss.android.d.SSDBHelper;
import com.ss.android.model.AbsArticle;
import com.ss.android.model.ItemActionV3;

import org.json.JSONObject;

public final class bb implements com.ss.android.bb {
    public boolean a;
    public boolean b;
    public String c;
    public int d;
    private static bb e;

    private bb() {

        this.a = false;
        this.b = false;
        this.d = -1;
        com.bytedance.frameworks.b.a.a.a(com.ss.android.bb.class, this);
    }

    public static bb a() {
        if(bb.e == null) {
            bb.e = new bb();
        }

        return bb.e;
    }

    public static void a(int action, long timestamp, AbsArticle arg10) {
        Object v0 = ComponentsManifest.findComponent(cc.class);
        if(v0 != null) {
            if(action == 18 || action == 19) {
                ((cc)v0).a(arg10);
            }

            SSDBHelper v0_1 = ((cc)v0).getDBHelper();
            if(v0_1 == null) {
                return;
            }

            v0_1.a(action, timestamp, arg10);
            ContentValues v1 = new ContentValues();
            v1.put("ss_op_key", Integer.valueOf(3));
            v1.put("op_item_type", Integer.valueOf(arg10.opItemType.getValue()));
            v1.put("item_id", Long.valueOf(arg10.groupId));
            v1.put("group_item_id", Long.valueOf(arg10.itemId));
            v1.put("aggr_type", Integer.valueOf(arg10.aggrType));
            v1.put("action", Integer.valueOf(action));
            v1.put("timestamp", Long.valueOf(timestamp));
            v0_1.asyncUpdate(v1);
        }
    }

    public static void a(int arg7, long arg8, AbsArticle arg10, boolean arg11) {
        ContentValues v1;
        Object v0 = ComponentsManifest.findComponent(cc.class);
        if(v0 != null) {
            SSDBHelper v0_1 = ((cc)v0).getDBHelper();
            if(v0_1 != null && arg10 != null && v0_1.a(arg10.opItemType) != null) {
                switch(arg7) {
                }

                if(0 != 0) {
                    v1 = new ContentValues();
                    v1.put("ss_op_key", Integer.valueOf(1));
                    v1.put("op_item_type", Integer.valueOf(arg10.opItemType.getValue()));
                    v1.put("item_id", Long.valueOf(arg10.groupId));
                    v1.put("group_item_id", Long.valueOf(arg10.itemId));
                    v1.put("tag", arg10.tag);
                    v1.put("digg_count", Integer.valueOf(arg10.diggCount));
                    v1.put("bury_count", Integer.valueOf(arg10.buryCount));
                    v1.put("comment_count", Integer.valueOf(arg10.commentCount));
                    v1.put("repin_count", Integer.valueOf(arg10.repinCount));
                    v0_1.asyncUpdate(v1);
                }

                if(arg8 <= 0) {
                    return;
                }

                v1 = new ContentValues();
                v1.put("ss_op_key", Integer.valueOf(4));
                v1.put("op_item_type", Integer.valueOf(arg10.opItemType.getValue()));
                v1.put("item_id", Long.valueOf(arg10.groupId));
                v1.put("group_item_id", Long.valueOf(arg10.itemId));
                v1.put("aggr_type", Integer.valueOf(arg10.aggrType));
                v1.put("action", Integer.valueOf(arg7));
                v1.put("timestamp", Long.valueOf(arg8));
                v0_1.asyncUpdate(v1);
            }
        }
    }

    public static void a(ItemActionV3 arg1) {
        Object v0 = ComponentsManifest.findComponent(ActionThreadV3.class);
        if(v0 != null) {
            SSDBHelper v0_1 = ((cc)v0).getDBHelper();
            if(v0_1 != null) {
                v0_1.a(arg1);
            }
        }
    }

    public static void a(ItemActionV3 arg6, AbsArticle arg7) {
        int v1 = 9;
        Object v0 = ComponentsManifest.findComponent(cc.class);
        if(v0 != null) {
            SSDBHelper v2 = ((cc)v0).getDBHelper();
            if(v2 != null) {
                if(arg7 != null && arg7 != null) {
                    switch(arg6.targetType) {
                        case 1: 
                        case 3: {
                            int v0_1 = -1;
                            if("dislike".equals(arg6.action)) {
                                v0_1 = v1;
                            }

                            if(v0_1 <= 0) {
                            }else {
                                v2.a(v1, arg6.timestamp, arg7);
                            }
                        }
                    }
                }
                v2.a(arg6);
            }
        }
    }

    public final void a(SharedPreferences.Editor arg3) {
        arg3.putString("repost_input_hint", this.c);
        arg3.putInt("impression_policy", this.d);
    }

    public final void a(SharedPreferences arg3) {
        this.a = arg3.getBoolean("comment_hint_showed", false);
        this.b = this.a;
        this.c = arg3.getString("repost_input_hint", null);
        this.d = arg3.getInt("impression_policy", -1);
    }

    public final void a(boolean arg1) {
    }

    public final boolean a(JSONObject arg5) {
        boolean v1 = true;
        boolean v0 = false;
        String v2 = arg5.optString("repost_input_hint");
        if(!android.support.design.a.isTextEquals(v2, this.c)) {
            this.c = v2;
            v0 = true;
        }

        int v2_1 = arg5.optInt("impression_policy", -1);
        if(v2_1 != this.d) {
            this.d = v2_1;
        }
        else {
            v1 = v0;
        }

        return v1;
    }

    public static void b(ItemActionV3 arg6) {
        Object v0 = ComponentsManifest.findComponent(cc.class);
        if(v0 != null) {
            SSDBHelper v0_1 = ((cc)v0).getDBHelper();
            if(v0_1 != null && arg6 != null) {
                ContentValues v1 = new ContentValues();
                v1.put("ss_op_key", Integer.valueOf(6));
                v1.put("group_id", Long.valueOf(arg6.d.groupId));
                v1.put("item_id", Long.valueOf(arg6.d.itemId));
                v1.put("aggr_type", Integer.valueOf(arg6.d.aggrType));
                v1.put("target_type", Integer.valueOf(arg6.targetType));
                v1.put("action", arg6.action);
                v1.put("timestamp", Long.valueOf(arg6.timestamp));
                v0_1.asyncUpdate(v1);
            }
        }
    }

    public final void b() {
    }

    public final void c() {
    }

    public final void d() {
    }
}

